package com.csw.pojo;

import lombok.Data;

import java.util.Random;

/**
 * @author A
 * @version 1.0
 * @description: 二维表格  里面有单元格
 * @date 2022/11/30 0:29
 */
@Data
public class Layer {
    //X轴y轴偏移量
    private int offsetX;
    private int offsetY;

    private Cell[][] cells=null;
    //行数
    private int rowNum;
    //列数
    private int colNum;
    //每页最大容量
    private int capacity;
    //每页多少cell
    private int size;
    //下一页
    private Layer nextLayer;

    public Layer(int rowNum,int colNum) throws Exception {
        this.cells=new Cell[rowNum][colNum];
        this.colNum=colNum;
        this.rowNum=rowNum;
        this.capacity=rowNum*colNum;
        this.offsetX=new Random().nextInt(100);
        this.offsetY=new Random().nextInt(100);
        if (capacity%3!=0){
            throw new Exception("容量不为3的倍数");
        }
        this.size=0;
    }

    public void show(){
        for (int i = 0; i < this.rowNum; i++) {
            for (int j = 0; j < this.colNum; j++) {
                Cell cell = cells[j][i];
                Brand brand = cell.getBrand();
                System.out.print(brand.getName()+"_");
            }
            System.out.println("");
        }
    }
}
